<template>
  <div class="infoset w100 h100">
    <vue-scroll :ops="ops">
      <info-collapse
        name="检测设置"
        :is-show="true"
        v-if="buttons.some(res=> btn_dete.includes(res.code))"
      >
        <detection-set :btn="btn_dete"></detection-set>
      </info-collapse>
      <info-collapse
        name="场所设置"
        :is-show="true"
        v-if="buttons.some(res=> btn_set.includes(res.code))"
      >
        <community-set :btn="btn_set"></community-set>
      </info-collapse>
      <info-collapse
        name="仓库设置"
        :is-show="true"
        v-if="buttons.some(res=> btn_sub.includes(res.code))"
      >
        <community-sub :btn="btn_sub"></community-sub>
      </info-collapse>
    </vue-scroll>
  </div>
</template>
<script>
import InfoCollapse from "./InfoCollapse";
import DetectionSet from "./DetectionSet";
import CommunitySet from "./CommunitySet";
import CommunitySub from "./CommunitySub.vue";
import { mapGetters } from "vuex";
export default {
  name: "infoSetting",
  components: {
    InfoCollapse,
    DetectionSet,
    CommunitySet,
    CommunitySub
  },
  data() {
    return {
      btn_dete: ["detection_update"],
      btn_set: ["community_insert", "community_update", "community_query", "community_delete"],
      btn_sub: ["store_insert", "store_update", "store_query", "store_delect"],
      ops: {
        scrollPanel: {
          scrollingX: false
        }
      },
      buttons: []
    };
  },
  computed: {
    ...mapGetters("user", {
      role: "getRole"
    })
  },
  mounted() {
    this.getButton();
  },
  methods: {
    /**
     * 从sessionStorage中获取所有的buttons
     * */
    getButton() {
      const buttonsSession = sessionStorage.getItem("buttons");
      if (!buttonsSession) {
        return [];
      }
      const stringButton = Base64.decode(buttonsSession);
      this.buttons = JSON.parse(stringButton);
    }
  }
};
</script>

<style lang="scss" scoped>
.infoset {
  box-sizing: border-box;
  padding: 24px 24px 22px 24px;
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #fff;
}
</style>
